﻿//----------------------------------------------------------------
// Copyright (C) 2015-2020 PeachSystem Co.,Ltd.
// All rights reserved.
//
// 文件:WXConfig.cs
// 摘要:微信配置类
// 说明:
//

//当前版本：1.0.0
//作    者：陶剑扬
//完成日期：2014-11-07
//----------------------------------------------------------------

using System;

namespace PeachSystem.XBase.WX.Entites
{
    public class WXConfig
    {
        #region 常量

        const string ENCODING_UTF8 = "utf-8";
        const string URL_API_TOKEN = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}";

        #endregion

        #region 属性

        /// <summary>
        /// Token(令牌)
        /// </summary>
        public string Token { get; set; }

        /// <summary>
        /// AccessToken
        /// </summary>
        public AccessToken AccessToken { get; set; }

        /// <summary>
        /// AppID
        /// </summary>
        public string AppID { get; set; }

        /// <summary>
        /// AppSecret
        /// </summary>
        public string AppSecret { get; set; }

        /// <summary>
        /// TokenApiUrl
        /// </summary>
        public string TokenApiUrl { get; set; }

        /// <summary>
        /// Encoding
        /// </summary>
        public string Encoding { get; set; }

        /// <summary>
        /// 密钥
        /// </summary>
        public string EncodingAESKey { get; set; }

        #endregion

         #region 构造

        /// <summary>
        /// 构造
        /// </summary>
        /// <param name="token">Token</param>
        /// <param name="appid">AppID</param>
        /// <param name="appsecret">AppSecret</param>
        /// <param name="aeskey">EncodingAESKey</param>
        public WXConfig(string token, string appid, string appsecret, string aeskey)
        {
            Token = token;
            AppID = appid;
            AppSecret = appsecret;
            TokenApiUrl = string.Format(URL_API_TOKEN, AppID, AppSecret);
            EncodingAESKey = aeskey;
            Encoding = ENCODING_UTF8;
        }

        /// <summary>
        /// 构造
        /// </summary>
        /// <param name="token">Token</param>
        /// <param name="appid">AppID</param>
        /// <param name="appsecret">AppSecret</param>
        /// <param name="aeskey">EncodingAESKey</param>
        /// <param name="encoding">Encoding</param>
        public WXConfig(string token, string appid, string appsecret, string aeskey, string encoding)
        {
            Token = token;
            AppID = appid;
            AppSecret = appsecret;
            TokenApiUrl = string.Format(URL_API_TOKEN, AppID, AppSecret);
            EncodingAESKey = aeskey;
            Encoding = encoding;
        }

        #endregion
    }
}
